package com.sqx.modules.packageTime.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.packageTime.entity.PackageTime;
import com.sqx.modules.packageTime.service.PackageTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * 包时价格-管理端
 * @author wuChang
 * @since 2024-05-07
 */
@RestController
@Api(value = "包时价格-管理端", tags = {"包时价格-管理端"})
@RequestMapping("/admin/packageTime/")
public class PackageTimeController {
    @Autowired
    private PackageTimeService packageTimeService;

    /**
     * 新增或修改包时价格
     *@param packageTime 包时价格
     */
    @ApiOperation("新增或修改包时价格")
    @PostMapping(value = "savePackageTime")
    public Result savePackageTime(PackageTime packageTime) {
        return packageTimeService.savePackageTime(packageTime);
    }

    /**
     * 获取包时价格列表
     * @param packageTime 包时价格
     */
    @ApiOperation("获取包时价格列表")
    @GetMapping(value = "getPackageTimeList")
    public Result getPackageTimeList(Integer page, Integer limit, PackageTime packageTime) {

        return Result.success().put("data", packageTimeService.getAdminPackageTimeList(page, limit, packageTime));
    }

    /**
     * 删除包时价格
     *@param timeId 包时价格id
     */
    @ApiOperation("删除包时价格")
    @PostMapping(value = "deletePackageTimeById")
    public Result deletePackageTimeById(Long timeId) {

        return packageTimeService.removeById(timeId) ? Result.success() : Result.error();
    }


    /**
     * 获取包时价格详情
     *@param timeId 包时价格id
     */
    @ApiOperation("获取包时价格详情")
    @GetMapping(value = "getPackageTimeById")
    public Result getPackageTimeById(Long timeId) {
        return Result.success().put("data", packageTimeService.getById(timeId));
    }

}